package com.hthy.futures.ui.activity;

import android.content.Context;
import android.content.Intent;
import android.graphics.Rect;
import android.support.v4.app.FragmentTransaction;
import android.view.View;
import android.view.ViewTreeObserver;
import android.widget.FrameLayout;
import android.widget.LinearLayout;

import com.hthy.futures.R;
import com.hthy.futures.base.BaseActivity;
import com.hthy.futures.ui.fragment.FundPwdFragment;
import com.hthy.futures.ui.fragment.PushMoneyFragment;
import com.hthy.futures.ui.fragment.PullMoneyFragment;
import com.hthy.futures.ui.fragment.ShareFragment;
import com.hthy.futures.ui.fragment.TradePwdFragment;
import com.hthy.futures.ui.fragment.UpdatepwdFragment;
import com.hthy.futures.utils.SoftHideKeyBoardUtil;
import com.hthy.futures.utils.TDevice;
import com.hthy.futures.view.TitleView;

import butterknife.Bind;

public class SlideCotainerActivity extends BaseActivity {
    @Bind(R.id.titleview)
    TitleView mTitleview;
    @Bind(R.id.fl_container)
    FrameLayout mFrameLayout;

    @Bind(R.id.lin_main)
    LinearLayout main;

    @Override
    protected int getContentView() {
        return R.layout.nav_activity_slide_cotainer;
    }

    public static void gotoActivity(Context context, int code) {
        context.startActivity(new Intent(context, SlideCotainerActivity.class).putExtra(context.getString(R.string.slideType), code));
    }

    @Override
    protected void initWidget() {
        super.initWidget();
        mTitleview.setBackBtn();
        mTitleview.setImgLeft( new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                TDevice.hideSoftKeyboard(mFrameLayout);
                finish();
            }
        });
        int material = getIntent().getIntExtra("slideType", 0);
        FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
        switch (material)
        {
            case 1:
                mTitleview.setTitle("密码修改");
                UpdatepwdFragment updateFrg = new UpdatepwdFragment();
                fragmentTransaction.add(R.id.fl_container, updateFrg);
                break;
            case 2:
                //SoftHideKeyBoardUtil.addLayoutListener(main,mFrameLayout);
                mTitleview.setTitle("入金申请");
                PullMoneyFragment pushFrg = new PullMoneyFragment();
                fragmentTransaction.add(R.id.fl_container, pushFrg);
                break;
            case 3:
               // SoftHideKeyBoardUtil.addLayoutListener(main,mFrameLayout);
                mTitleview.setTitle("出金申请");
                PushMoneyFragment pullFrg = new PushMoneyFragment();
                fragmentTransaction.add(R.id.fl_container, pullFrg);


                // 替换成activity写法 方案  ---还暂时不能这样，因为activity我没封装相关的协议逻辑
               // startActivity(new Intent(this,PushMoneyActivity.class));
                break;
            case 4:
                mTitleview.setTitle("交易密码");
                TradePwdFragment tradePwdFragment = new TradePwdFragment();
                fragmentTransaction.add(R.id.fl_container, tradePwdFragment);
                break;
            case 5:
                mTitleview.setTitle("资金密码");
                FundPwdFragment fundPwdFragment = new FundPwdFragment();
                fragmentTransaction.add(R.id.fl_container, fundPwdFragment);
                break;
        }
        fragmentTransaction.commit();

      //  SoftHideKeyBoardUtil.assistActivity(this);

    }

}
